package dev.ideas.funkyj.tuple;

import dev.ideas.funkyj.sequence.Sequence;

import java.util.Iterator;

/**
 */
public abstract class Pair<T1, T2> extends Tuple {
    public Pair() {}
    public abstract T1 first();
    public abstract T2 second();

    public static <T1, T2> Pair<T1, T2> of(final T1 t1, final T2 t2) {
        return new Pair<T1, T2>() {
            @Override public T1 first() { return t1; }
            @Override public T2 second() { return t2; }
        };
    }

    /*@Override*/ public Iterator iterator() {
        return Sequence.from(first(), second()).iterator();
    }

    @Override public String toString() { return "(" + first() + "," + second() + ")"; }
}
